Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finance #124

Merged
merged 6 commits into from
Sep 25, 2023
Merged

Finance #124

merged 6 commits into from
Sep 25, 2023

Conversation

xchwan
Copy link
Collaborator

@xchwan xchwan commented Aug 26, 2023

Types of changes

  • New feature

Description

add finance bot

Checklist:

  • Add test cases to all the changes you introduce
  • Run poetry run pytest locally to ensure all linter checks pass
  • Update the documentation if necessary

"on_failure_callback": lambda x: "Need to send notification to Discord",
}
dag = DAG(
"DISCORD_CHORES_REMINDER",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might need to rename this~

write_to_bigquery(df_diff)
# push to discord
webhook_url = os.getenv("discord_data_stratagy_webhook")
username = "財務機器人"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Comment on lines +14 to +17
# read xls from google doc to df.
df_xls = read_google_xls_to_df()
# read bigquery to df.
df_bigquery = read_bigquery_to_df()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for writing comments~


def write_to_bigquery(df) -> None:
project_id = "pycontw-225217"
dataset_id = "test"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remember to update the dataset id~

Comment on lines 25 to 26
msg = refine_diff_df_to_string(df_diff)
discord.send_webhook_message(webhook_url, username, msg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just my two cents, but maybe we don't need to send any msg if there's no updates. Otherwise, that channel might be very noisy

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have modify if msg is no data it didn't send msg

Comment on lines +29 to +31
def df_difference(df_xls, df_bigquery) -> pd.DataFrame:
merged = pd.merge(df_xls, df_bigquery, how="outer", indicator=True)
return merged[merged["_merge"] == "left_only"].drop("_merge", axis=1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +94 to +96
else:
for row in df.itertuples(index=False):
msg += f"{row[0]}, 花費: {row[1]}, {row[3]}, {row[4]}\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯. What do you think about calculating the total expenses as well as the expenses per group in your next PR?

Copy link
Collaborator

@david30907d david30907d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFG!

@xchwan xchwan merged commit 22fc71c into master Sep 25, 2023
@xchwan xchwan deleted the finance branch September 25, 2023 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants